﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<!--back-->
<div class="w_980">
	<!--back_box-->
	<div class="back_box clearfix">
        <% 
            Html.RenderPartial("~/Views/Shared/VipCenterList.ascx");
        %>
    	<!--right-->
        <div class="back_main">
        	<h3>账户信息</h3>
            <% 
                BIZ.IncomeExpensesOper ieo = new BIZ.IncomeExpensesOper();
                int pageno = Request["pageno"] == null ? 1 : int.Parse(Request["pageno"].ToString());//当前页
                int pagesize = 15;//单页记录数
                int count = 0;//总记录数
                int pageNumber = 0;//总页数   
                IList li = ieo.userGetIncomeExpenses(pageno, pagesize, ((DomainModel.UserInfo)Session["user"]).u_id);
                StringBuilder sb = new StringBuilder();
                
                int i = 1;//判断基数偶数
                decimal inM = 0;//收入
                decimal outM = 0;//支出
                foreach (Hashtable tb in li)
                {
                    if (tb["total"] == null)
                    {
                        sb.Append("<tr " + ((i % 2) != 0 ? "class=\"tr_bg\"" : "") + ">");
                        sb.Append("<td>" + DateTime.Parse(tb["ie_time"] == null ? DateTime.Now.ToString() : tb["ie_time"].ToString()).ToString("yyyy-MM-dd") + "</td>");
                        decimal ie_money = Math.Round(decimal.Parse(tb["ie_money"] == null ? "0" : tb["ie_money"].ToString()), 2);
                        if (ie_money > 0)
                        {
                            inM += ie_money;
                            sb.Append("<td class=\"txt_green\">+" + ie_money.ToString() + "￥</td>");
                        }
                        else if (ie_money < 0)
                        {
                            outM += ie_money;
                            sb.Append("<td class=\"txt_red\">" + ie_money.ToString() + "￥</td>");
                        }
                        else
                            sb.Append("<td class=\"txt_red\">0￥</td>");
                        sb.Append("<td>" + tb["ie_statetext"].ToString() + "</td>");
                        sb.Append("<td>" + (tb["ie_remark"] == null ? "" : tb["ie_remark"].ToString()) + "</td>");
                        sb.Append("</tr>");
                        i++;
                    }
                    else
                        count = (tb["total"] == null ? 0 : int.Parse(tb["total"].ToString()));
                }
            %>
            <div class="money_info_box">
            	<div class="money_title"><strong>收支明细</strong></div>
                <div class="money_info"><span>收入：<b><%=inM %></b>元</span><span>支出：<em><%=outM %></em>元</span><span>余额：<strong><%=(inM+outM) %></strong>元</span></div>
                <!--table_box-->
                <div class="table_box">
                	<table>
                    	<thead>
                        	<tr>
                            	<th width="90">日期</th>
                            	<th width="110">金额</th>
                            	<th width="110">是否加入余额计算</th>
                            	<th>备注</th>
                            </tr>
                        </thead>
                        <tbody>
                             <%
                                 Response.Write(sb.ToString());
                            %>
 
                        </tbody>
                    </table>
                </div>
            	<!--bottom_bar-->
            </div>
                    <!--pager-->
        <div class="pager">
        <%
            pageNumber = ((count % pagesize) == 0 ? (count / pagesize) : ((count / pagesize) + 1));
            int start = pagesize * (pageno - 1) + 1;
            if (start < 0)
                start = 0;
            int end = (start + pagesize-1);
            if (pageno == pageNumber)
            {
                if ((count % pagesize) != 0)
                {
                    end = (start + (count % pagesize) - 1);
                }
            }
        %>
            <p class="left"><%=count%> 条记录，显示第 <%=start %> 条 - 第 <%=end %> 条记录</p>
            <p class="right"><a href="/vipcenter/costlist.html?f=d1&pageno=1" title="首页" class="a1 a1_n"></a>
            <a href="/vipcenter/costlist.html?f=d1&pageno=<%=(pageno==1?1:pageno-1) %>" title="上一页" class="a2"></a><span>第<b><%=pageno %></b>页/共 <%=pageNumber %> 页</span>
            <a href="/vipcenter/costlist.html?f=d1&pageno=<%=(pageno==pageNumber?pageNumber:pageno+1) %>" title="下一页" class="a3"></a><a href="/vipcenter/costlist.html?f=d1&pageno=<%=pageNumber %>" title="末页" class="a4"></a>
            <select id="sPage">
            <% 
                for (int k = 1; k <= pageNumber;k++ )
                    Response.Write("<option value=\"" + k.ToString() + "\">" + k.ToString() + "</option>");
            %>
            </select></p>
            <script type="text/javascript" language="javascript">
                $(function () {
                    $("#sPage").val(<%=pageno %>);
                    $("#sPage").change(function () {
                        window.location.href = "/vipcenter/costlist.html?f=d1&pageno=" + $("#sPage").val();
                    });
                })
            </script>
        </div>
        </div>
    </div>
</div>


</asp:Content>
